{% extends "base.html" %}
{% load static %}
{% load gravatar %}
{% load render_thermo %}
{% load databasefilters %}



{% block title %}Thermodynamics Data{% endblock %}

{% block extrahead %}
<script src="https://code.highcharts.com/6/highcharts.js"></script>
<script src="{% static 'js/highcharts.theme.js' %}" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {

    Cpseries = new Array();
    Hseries = new Array();
    Sseries = new Array();
    Gseries = new Array();
    
    {% for entry, thermo, source, href, nasa in thermo_data_list %}
    {{ thermo|get_thermo_data:user }}
    {% include "thermoModel.js" %}
    {% endfor %}

    MathJax.Hub.Queue(function() {
        plotHeatCapacity('plotCp', Cpseries);
        plotEnthalpy('plotH', Hseries);
        plotEntropy('plotS', Sseries);
        plotFreeEnergy('plotG', Gseries);
    });

});
</script>
{% endblock %}

{% block navbar_items %}
<li><a href="{% url 'database:index' %}">Database</a></li>
<li><a href="{% url 'database:thermo' %}">Thermodynamics</a></li>
{% endblock %}

{% block sidebar_items %}
{% endblock %}

{% block page_title %}Thermodynamics Data{% endblock %}

{% block page_body %}
<h2>Structure</h2>
<p>
{{ structure|safe }}
</p>
If you have thermodynamic data to contribute to this species, you can add an entry here: 
{% if molecule.get_radical_count == 0 %}
<a href="{% url 'database:thermo-entry-new' section='depository' subsection='stable' adjlist=molecule.to_adjacency_list %}"><button type="button">Add new entry</button></a>.
{% else %}
<a href="{% url 'database:thermo-entry-new' section='depository' subsection='radical' adjlist=molecule.to_adjacency_list %}"><button type="button">Add new entry</button></a>.
{% endif %}

{% if user.is_authenticated %}
You are logged in as {{ user.get_full_name }}</a> 
{% else %}
You must <a href="{% url 'login' %}?next={{ request.path }}">log in first.</a>
{% endif %}
<br/><br/>

<h2>Thermodynamic Data</h2>

{% for entry, thermo, source, href, nasa in thermo_data_list %}
{% if href != '' %}<a href="{{ href }}">{% endif %}
<h3>Result #{{ forloop.counter }} &ndash; {{ source }}</h3>
{% if href != '' %}</a>{% endif %}

{% if entry.label != '' %}
<p>Species label: {{ entry.label }}</p>
{% endif %}
{% if source == 'Group additivity' %}
<p>
Comments: 
{% for word in word_list %}
{% if word in ref_dict %}
<a href="{{ref_dict|get_items:word}}"> {{word}} </a>
{% else %}
{{word}}
{% endif %}
{% endfor %}
<P>
Symmetry number: {{ symmetry_number }}
<p>
{% endif %}
{{ thermo|render_thermo_math:user }}
<br/>
CHEMKIN format NASA Polynomial:
<br/>
<font face='courier'>{{ nasa|renderNASA }}</font>
<P>
{% endfor %}

<div id="plotCp" style="width: {{ plotWidth }}px; height: {{ plotHeight }}px; margin: auto;"></div>
<div id="plotH" style="width: {{ plotWidth }}px; height: {{ plotHeight }}px; margin: auto;"></div>
<div id="plotS" style="width: {{ plotWidth }}px; height: {{ plotHeight }}px; margin: auto;"></div>
<div id="plotG" style="width: {{ plotWidth }}px; height: {{ plotHeight }}px; margin: auto;"></div>

{% endblock %}
